/*
 * sgf-test.js
 * http://dev.akinao.com/
 */
(function(){
	var t=akinao.test.assertEqual;
	var Sgf=akinao.game.Sgf;
	t('[{}]',new Sgf().sgf.toSource());
	t('[{}]',new Sgf('()').sgf.toSource());
//	t('[{}]',new Sgf('(;)').sgf.toSource());
//	t('[{}]',new Sgf('(;;)').sgf.toSource());
//	t('[{a:"1"}]',new Sgf('(;a[1];)').sgf.toSource());
	t('[{a:"1"}, {a:"2"}, {a:"3"}]',
		new Sgf('(;a[1];a[2];a[3])').sgf.toSource());
//	t('[{a:"1"}, {a:"2"}, {a:"3"}]',
//		new Sgf('(;;a[2];a[3])').sgf.toSource());
	t('[{a:["1", "2", "3"]}, {a:["a", "b"]}, {c:["3", "2"]}]',
		new Sgf('(;a[1][2][3];a[a][b];c[3][2])').sgf.toSource());
	var s=new Sgf();
	var sg=s.sgf;
	s.append({a:1});
	t('[{}, {a:"1"}]',sg.toSource());
	s.append({b:2});
	s.append({c:3});
	t('[{}, {a:"1"}, {b:"2"}, {c:"3"}]',sg.toSource());
	s.previous();
	t('({b:"2"})',s.get().toSource());
	s.append({d:4});
	t('[{}, {a:"1"}, {b:"2"}, [[{c:"3"}], [{d:"4"}]]]',sg.toSource());
	t('[{c:"3"}, {d:"4"}]',s.get().toSource());
	s.append({e:5});
	t('[{}, {a:"1"}, {b:"2"}, [[{c:"3"}], [{d:"4"}], [{e:"5"}]]]',sg.toSource());
	t('[{c:"3"}, {d:"4"}, {e:"5"}]',s.get().toSource());
	s.remove(1);
	t('[{}, {a:"1"}, {b:"2"}, [[{c:"3"}], [{e:"5"}]]]',sg.toSource());
	t('[{c:"3"}, {e:"5"}]',s.get().toSource());
	s.remove();
	t('[{}, {a:"1"}, {b:"2"}, {e:"5"}]',sg.toSource());
	t('({e:"5"})',s.get().toSource());
	s.previous();
	s.previous();
	s.remove();
	t('[{}]',sg.toSource());
	s.append({a:1});
	s.append({b:2});
	s.append({c:3});
	s.previous();
	s.append({d:4});
	s.append({e:5},1);
	s.append({f:6});
	s.append({g:7});
	t('[{}, {a:"1"}, {b:"2"}, [[{c:"3"}], [{d:"4"}, {e:"5"}, {f:"6"}, {g:"7"}]]]',sg.toSource());
	t('(;;a[1];b[2](;c[3])(;d[4];e[5];f[6];g[7]))',s.toSgf());
	s.previous();
	s.previous();
	s.previous();
	s.remove();
	t('[{}, {a:"1"}, {b:"2"}, {d:"4"}, {e:"5"}, {f:"6"}, {g:"7"}]',sg.toSource());
	s.previous();
	s.append({h:8},1);
	s.append({i:9},1);
	s.previous();
	t('[{d:"4"}, {h:"8"}]',s.get().toSource());
	s.remove(1);
	t('[{}, {a:"1"}, {b:"2"}, {d:"4"}, {e:"5"}, {f:"6"}, {g:"7"}]',sg.toSource());
	t('(;;a[1];b[2];d[4];e[5];f[6];g[7])',s.toSgf());
})();
